package com.cwt_taxi_xa.protocol;

import android.text.TextUtils;

import com.cwt_taxi_xa.constants.Constants;
import com.cwt_taxi_xa.constants.SPConstants;
import com.cwt_taxi_xa.util.SPUtils;
/**
 * 设备业务类
 * @author Administrator
 *
 */
public class DeviceBiz {

	/*private static String firmVersionCode;

	 *//**保存硬件版本号*//*
	public static void setFirmVersionCode(String firmVersionCode) {
		DeviceBiz.firmVersionCode = firmVersionCode.replaceAll(".", "");
	}

	  *//**获取硬件版本号*//*
	public static String getFirmVersionCode() {
		return firmVersionCode;
	}
	   */
	/**获取车牌号*/
	public static String getCarNumber() {
//		String carNumber = "贵"+getCarNumberSingleLetter();
		String carNumber = "陕"+getCarNumberSingleLetter();
		return carNumber;
	}

	/**获取车牌号 ascall[6]*/
	public static String getCarNumberSingleLetter() {
		String carNumber = SPUtils.getParamString(SPConstants.SPK_carcode, SPConstants.SPV_carcode);
		carNumber = carNumber.replaceAll("粤", "");
		carNumber = carNumber.replaceAll("测", "");
		carNumber = carNumber.replaceAll("灯", "");
		carNumber = carNumber.replaceAll("陕", "");
		if(!TextUtils.isEmpty(carNumber) && SPConstants.SPK_carcode_prefix){
			if(!carNumber.startsWith("A")){
				carNumber = "A"+ carNumber;
			}
		}
		return carNumber;
	}

	/**保存车牌号 ascall[6]*/
	public static void setCarNumber(String carNumber) {
		//		carNumber = Constants.CAR_NUMBER;
		carNumber = carNumber.replaceAll("粤", "");
		SPUtils.setParam(SPConstants.SPK_carcode, carNumber);
	}


	public static void setCarNumberCorrection(boolean value) {
		//		carNumber = Constants.CAR_NUMBER;
		SPUtils.setParam(SPConstants.Correction_carcode, value);
	}

	public static boolean getCarNumberCorrection() {
		//		carNumber = Constants.CAR_NUMBER;
		return SPUtils.getParamBoolean(SPConstants.Correction_carcode, true);
	}

	/**获取sim卡号*//*
	public static String getSimNumber() {
		String carNumber = SPUtils.getParamString(SPConstants.SIM_NUMBER, Constants.SIM);
		return carNumber;
	}

	 *//**保存sim卡号*//*
	public static void setSimNumber(String simNumber) {
		SPUtils.setParam(SPConstants.SIM_NUMBER, simNumber);
	}

	  *//**获取设备号*/
	public static String getDeviceCode() {
		String sim = SPUtils.getParamString(SPConstants.SPK_clientcode, SPConstants.SPV_clientcode);
		return sim;
	}

	/**保存设备号*/
	public static void setDeviceCode(String deviceCode) {
		SPUtils.setParam(SPConstants.SPK_clientcode, deviceCode);
	}

	/**是否第一次*//*
	public static boolean isFirstTime() {
		boolean firstTime = SPutil.defaultPref().getBoolean("first_time", true);
		return firstTime;
	}

	 *//**修改第一次*//*
	public static void setFirstTime(boolean firstTime) {
		SPutil.defaultEditor().putBoolean("first_time", firstTime);
	}*/

	/**
	 * 驾驶员每次通话时间	0x0046	默认60秒
	 * @return
	 */
	public static int getMaxCall(){
		int paramValue = SPUtils.getParamInteger(SPConstants.PARAMS_MAX_CALL_EACH_TIME, 30);
		return paramValue;
	}

	/**
	 * 驾驶员每次通话时间	0x0046	默认60秒
	 * @return
	 */
	public static void setMaxCall(int paramValue){
		SPUtils.setParam(SPConstants.PARAMS_MAX_CALL_EACH_TIME, paramValue);
	}

	/**
	 * 未登录汇报时间间隔	0x0022	默认30秒
	 * @return
	 */
	public static int getOffLineHeartTime(){
		int paramValue = SPUtils.getParamInteger(SPConstants.PARAMS_OFFLINE_REPORT_TIME, 60);
		return paramValue;
	}

	/**
	 * 未登录汇报时间间隔	0x0022	默认30秒
	 * @return
	 */
	public static void setOffLineHeartTime(int paramValue){
		SPUtils.setParam(SPConstants.PARAMS_OFFLINE_REPORT_TIME, paramValue);
	}

	/**
	 * 重车汇报时间间隔	0x0026	默认30秒
	 * @return
	 */
	public static int getFullCarHeartTime(){
		int paramValue = SPUtils.getParamInteger(SPConstants.PARAMS_FULL_REPORT_TIME, 30);
		return paramValue;
	}

	/**
	 * 重车汇报时间间隔	0x0026	默认30秒
	 * @return
	 */
	public static void setFullCarHeartTime(int paramValue){
		SPUtils.setParam(SPConstants.PARAMS_FULL_REPORT_TIME, paramValue);
	}

	/**
	 * 空车汇报时间间隔	0x0025	默认30秒
	 * @return
	 */
	public static int getEmptyCarHeartTime(){
		int paramValue = SPUtils.getParamInteger(SPConstants.PARAMS_EMPTY_REPORT_TIME, 30);
		return paramValue;
	}

	/**
	 * 空车汇报时间间隔	0x0025	默认30秒
	 * @return
	 */
	public static void setEmptyCarHeartTime(int paramValue){
		SPUtils.setParam(SPConstants.PARAMS_EMPTY_REPORT_TIME, paramValue);
	}

	/**
	 * 心跳间隔	0x0001	默认30秒,西交投要求15分钟
	 * @return
	 */
	public static int getHeartTime(){
		int paramValue = SPUtils.getParamInteger(SPConstants.PARAMS_HEART_TIME, 60*15);
		return paramValue;
	}

	/**
	 * 心跳间隔	0x0001	默认30秒
	 * @return
	 */
	public static void setHeartTime(int paramValue){
		SPUtils.setParam(SPConstants.PARAMS_HEART_TIME, paramValue);
	}

	/**获取switcher*/
	public static int getSwitcher() {
		int Switcher = SPUtils.defaultPref().getInt(SPConstants.SWITCHER, 1);
		return Switcher;
	}

	/**保存Switcher*/
	public static void setSwitcher(int Switcher) {
		SPUtils.defaultEditor().putInt(SPConstants.SWITCHER, Switcher).commit();
	}

	/**获取SwitcherBak*/
	public static int getSwitcherBak() {
		int SwitcherBak = SPUtils.defaultPref().getInt(SPConstants.SWITCHER_BAK, (Constants.SWITCHER_BAK_ENABLE ?1:0));
		return SwitcherBak;
	}

	/**保存SwitcherBak*/
	public static void setSwitcherBak(int SwitcherBak) {
		SPUtils.defaultEditor().putInt(SPConstants.SWITCHER_BAK, SwitcherBak).commit();
	}

	/**获取ip*/
	public static String getIp() {
		String ip = SPUtils.defaultPref().getString(SPConstants.PARAMS_SERVER_IP, SPConstants.SPV_ip);
		return !Constants.PORT_PROTECT ? ip:SPConstants.SPV_ip;
	}

	/**保存ip*/
	public static void setIp(String ip) {
		SPUtils.defaultEditor().putString(SPConstants.PARAMS_SERVER_IP, ip).commit();
	}

	/**获取ip*/
	public static String getIpBak() {
		String ip = SPUtils.defaultPref().getString(SPConstants.PARAMS_SERVER_IP_BAK, SPConstants.SPV_ip);
		return !Constants.PORT_PROTECT ? ip:SPConstants.SPV_ip;
	}

	/**保存ip*/
	public static void setIpBak(String ipBak) {
		SPUtils.defaultEditor().putString(SPConstants.PARAMS_SERVER_IP_BAK, ipBak).commit();
	}

	/**获取port*/
	public static String getPort() {
		String ip = SPUtils.defaultPref().getString(SPConstants.PARAMS_SERVER_PORT, SPConstants.SPV_PORT);
		return !Constants.PORT_PROTECT ?ip:SPConstants.SPV_PORT;
	}

	/**保存port*/
	public static void setPort(String port) {
		SPUtils.defaultEditor().putString(SPConstants.PARAMS_SERVER_PORT, port).commit();
	}

	/**获取port*/
	public static String getPortBak() {
		String portBak = SPUtils.defaultPref().getString(SPConstants.PARAMS_SERVER_PORT_BAK, SPConstants.SPV_PORT);
		return !Constants.PORT_PROTECT ?portBak:SPConstants.SPV_PORT_BAK;
	}

	/**保存port*/
	public static void setPortBak(String portBak) {
		SPUtils.defaultEditor().putString(SPConstants.PARAMS_SERVER_PORT_BAK, portBak).commit();
	}

	/**获取MsgBgswitcher*/
	public static int getMsgBgSwitcher() {
		int Switcher = SPUtils.defaultPref().getInt(SPConstants.MSG_BG_SWITCHER, 1);
		return Switcher;
	}

	/**保存MsgBgSwitcher*/
	public static void setMsgBgSwitcher(int Switcher) {
		SPUtils.defaultEditor().putInt(SPConstants.MSG_BG_SWITCHER, Switcher).commit();
	}

	/**
	 * 0：白色
	 * 1：绿色
	 * @param Switcher
	 */
	public static int getMsgColor() {
		int Switcher = SPUtils.defaultPref().getInt(SPConstants.MSG_COLOR, 1);
		return Switcher;
	}

	/**
	 * 0：白色
	 * 1：绿色
	 * @param Switcher
	 */
	public static void setMsgColor(int Switcher) {
		SPUtils.defaultEditor().putInt(SPConstants.MSG_COLOR, Switcher).commit();
	}

	/**
	 * 0：滚动
	 * 1：静止
	 * @param Switcher
	 */
	public static int getMsgShowType() {
		int Switcher = SPUtils.defaultPref().getInt(SPConstants.MSG_SHOW_TYPE, 0);
		return Switcher;
	}

	/**
	 * 0：滚动
	 * 1：静止
	 * @param Switcher
	 */
	public static void setMsgShowType(int Switcher) {
		SPUtils.defaultEditor().putInt(SPConstants.MSG_SHOW_TYPE, Switcher).commit();
	}

	/**
	 * 日夜模式
	 * 0:日间模式
	 * 1:夜间模式
	 * @return
	 */
	public static int getDayNightMode(){
		int paramValue = SPUtils.defaultPref().getInt("day_night", 0);
		return paramValue;
	}

	/**
	 * 日夜模式
	 * 0:日间模式
	 * 1:夜间模式
	 */
	public static void setDayNightMode(int paramValue){
		SPUtils.defaultEditor().putInt("day_night", paramValue).commit();
	}

	/**
	 * 屏保开关
	 * 0:关
	 * 1:开
	 * @return
	 */
	public static int getScreenProtect(){
		int paramValue = SPUtils.defaultPref().getInt("screen_protect", 0);
		return paramValue;
	}

	/**
	 * 屏保开关
	 * 0:关
	 * 1:开
	 * @return
	 */
	public static void setScreenProtect(int paramValue){
		SPUtils.defaultEditor().putInt("screen_protect", paramValue).commit();
	}
}
